// FIXME 这个T是否符合Array<U>的结构规则，符合的话，我这个U就能返回出来,否则返回参数本身T
type Arr = Array<string | number>
type get<T> = T extends Array<infer U> ? U : T
type X = get<Arr>

type Obj1 = { name: string; age: number }
type Get1<T> = T extends { name: infer U; age: infer U } ? U : T
type EE1 = Get1<Obj1> // u 则是联合类型

// TODO: infer 类型提取
type User = [string, number, boolean]
// 提取第一个元素
type GetFirst<T> = T extends [infer U, ...any[]] ? U : T
type First = GetFirst<User>
// 提取最后一个元素
type GetLast<T> = T extends [...any[], infer U] ? U : T
type Last = GetLast<User>
// 剔除最后一元素
type PopLast<T> = T extends [...infer Rest, infer U] ? Rest : T
type Rest = PopLast<User>

// TODO: infer 递归
type Arrs = [1, 2, 3, 4]
// 颠倒顺序
type Revert<T extends any[]> = T extends [infer First, ...infer Rest] ? [...Revert<Rest>, First] : T
type RevertedArr = Revert<Arrs>
